package com.zijidelu.luframework.constant;

import java.util.Arrays;
import java.util.List;

/**
 * 类名常量。
 *
 * @author ZIJIDELU
 * @datetime 2025/10/28 17:49
 */
public interface ClassNameConstant {
    /**
     * 常见数据模型类后缀列表
     */
    List<String> DATA_MODEL_SUFFIXES = Arrays.asList(
            "Entity", "PO", "POJO", "DO", "EntityDO", "EntityPO", "EntityPOJO", "DTO", "Dto", "DomainEntity",
            "DataModel", "Model", "AggregateRoot"
    );

    /**
     * 获取领域名称
     *
     * @param poClass 实体类
     * @return 领域名称
     */
    static String calcDomainName(Class<?> poClass) {
        String result = poClass.getSimpleName();

        // 检查并移除后缀
        for (String suffix : ClassNameConstant.DATA_MODEL_SUFFIXES) {
            if (result.endsWith(suffix)) {
                result = result.substring(0, result.length() - suffix.length());
                break; // 只移除一个后缀，避免连续移除
            }
        }

        return result;
    }
}
